router: refactor calc_ra_lifetime; redefine ra_lifetime as uint32_t
authorPaul Donald <[email protected]>
Thu, 9 Oct 2025 21:35:31 +0000 (23:35 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 13 Oct 2025 07:52:51 +0000 (09:52 +0200)
ra_lifetime no longer holds negative values, because we no longer do
'init' when we do calc_ra_lifetime, instead we do init at init time.

Now ra_lifetime holds only >0 values.

Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/225
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/odhcpd.h
src/router.c

index be80646860be1787776bcf037b093e894546a46a..af4ec2ed0082b6c9f92b86321461c700e82dc977 100644 (file)
@@ -364,7 +364,7 @@ struct interface {
        int route_preference;
        int ra_maxinterval;
        int ra_mininterval;
-       int ra_lifetime;
+       uint32_t ra_lifetime;
        uint32_t ra_reachabletime;
        uint32_t ra_retranstime;
        uint32_t ra_hoplimit;
index c352d19ea68e8825598771e377363674fbaf18f8..fd8e9e38a9e234b68569e70f03d5f4ab691befc7 100644 (file)
@@ -363,7 +363,7 @@ static uint32_t calc_ra_lifetime(struct interface *iface, uint32_t maxival)
 {
        uint32_t lifetime = iface->max_preferred_lifetime;
 
-       if (iface->ra_lifetime >= 0) {
+       if (iface->ra_lifetime > 0) {
                lifetime = iface->ra_lifetime;
        }